Title: SQL BT (By-BKK) / 03 Constraints
Tags: Obsidian_to_Anki

Q: What clause is used in SQL to filter rows based on conditions?
A: WHERE

Q: True or False: WHERE can join multiple constraints using AND and OR.
A: True

Q: What SQL operators are used to compare numbers?
A: =, !=, <, >, <=, >=

Q: How is BETWEEN used in SQL?
A: For checking if a value is within a range

Q: How do you select values not in a range in SQL?
A: Use NOT BETWEEN … AND …

Q: Which SQL keyword checks if a value is among multiple options?
A: IN (…)

Q: What does NOT IN (…) do in SQL?
A: Selects values not in specified options

Q: What SQL clause makes queries faster by excluding data?
A: WHERE

Q: Is writing SQL keywords in all caps required?
A: No, but it helps readability

Q: Reverse card: WHERE
A: Which clause filters rows based on conditions in SQL?

Q: Reverse card: True
A: Can WHERE combine multiple constraints using AND and OR?

Q: Reverse card: =, !=, <, >, <=, >=
A: Which operators compare numbers in SQL?

Q: Reverse card: IN (…)
A: What SQL keyword checks if a value is among several options?

Q: Reverse card: BETWEEN
A: Which keyword checks if a value is between two numbers in SQL?

Q: Write an example SQL query to get movies released between 2000 and 2010.
A: SELECT * FROM movies WHERE year BETWEEN 2000 AND 2010;

Q: Write a SQL query to select movies NOT released between 2000 and 2010.
A: SELECT * FROM movies WHERE year NOT BETWEEN 2000 AND 2010;

Q: How can you find titles and years of the first 5 Pixar movies?
A: SELECT title, year FROM movies WHERE id <= 5

Q: Write a query to find the movie with id = 6.
A: SELECT * FROM movies WHERE id = 6

Q: Reverse card: SELECT * FROM movies WHERE year BETWEEN 2000 AND 2010;
A: How do you select Pixar movies released between 2000 and 2010?

Q: Reverse card: SELECT title, year FROM movies WHERE id <= 5
A: How do you find the first 5 Pixar movies and their year?

Q: Reverse card: SELECT * FROM movies WHERE id = 6
A: Which query finds the movie with id 6?

Q: Which operator is used for case-sensitive string inequality comparison?
A: != or <>

Q: How do you perform case-insensitive string comparison in SQL?
A: LIKE

Q: True or False: LIKE is case-insensitive in SQL.
A: True

Q: What SQL operator is used for pattern matching any sequence of characters?
A: %

Q: How do you match a single character in a string using SQL?
A: _

Q: What does IN (…) do in a SQL WHERE clause?
A: Checks if a string exists in a list

Q: What is the use of NOT IN (…) in SQL?
A: Checks if a string does not exist in a list

Q: Why must all strings be quoted in SQL statements?
A: To distinguish them from SQL keywords

Q: True or False: Full-text search is best handled by dedicated libraries, not SQL.
A: True

Q: Reverse card: =
A: Which operator checks for case-sensitive exact string match in SQL?

Q: Reverse card: LIKE
A: Which operator allows case-insensitive string comparison and pattern matching?

Q: Reverse card: %
A: Which operator matches any number of characters in SQL pattern matching?

Q: Reverse card: All strings must be quoted
A: Why do you need quotes for text values in SQL?

Q: Write an example SQL query to find all Toy Story movies.
A: SELECT * FROM movies WHERE title LIKE 'Toy Story%';

Q: What is the query for movies directed by John Lasseter?
A: SELECT * FROM movies WHERE director = 'John Lasseter';

Q: Give the SQL query for movies not directed by John Lasseter with their director.
A: SELECT * FROM movies WHERE director != 'John Lasseter';

Q: How do you find all WALL-* movies using SQL?
A: SELECT * FROM movies WHERE title LIKE 'WALL-%';

Q: Reverse card: SELECT * FROM movies WHERE title LIKE 'Toy Story%';
A: How do you find all Toy Story movies using SQL?

Q: Reverse card: SELECT * FROM movies WHERE director = 'John Lasseter';
A: What query finds all movies directed by John Lasseter?

Q: Reverse card: SELECT * FROM movies WHERE director != 'John Lasseter';
A: How do you find all movies not directed by John Lasseter and their director?

Q: Reverse card: SELECT * FROM movies WHERE title LIKE 'WALL-%';
A: How do you find all WALL-* movies using SQL?

Q: Reverse card: IN (…)
A: Which operator checks if a value matches one from a given list?